package org.googlecode.openapi_java;

import org.json.JSONException;
import org.json.JSONObject;

public class Status implements IVkPossession {
    private static final int STATUS_NOT_SET_ID = -1;
    
    public static int getStatusNotSetId() {
		return STATUS_NOT_SET_ID;
	}
	public long getTime() {
		return time;
	}

	public String getActivity() {
		return activity;
	}

	public long getId() {
		return id;
	}

	public long getUid() {
		return uid;
	}

	private long time;
    private String activity;
    private long id;
    private long uid;
    Status(){}
    
    public static Status fromJSON(JSONObject jsonObject) throws JSONException {
        Status status = new Status();
        if (jsonObject.has("time")) status.time = jsonObject.getLong("time");
        if (jsonObject.has("timestamp")) status.time = jsonObject.getLong("timestamp");
        if (jsonObject.has("created")) status.time = jsonObject.getLong("created");
        if (jsonObject.has("text")) status.activity = jsonObject.getString("text");
        if (jsonObject.has("activity")) status.activity = jsonObject.getString("activity");
        if (jsonObject.has("uid")) status.uid = jsonObject.getLong("uid");
        if (jsonObject.has("id")) status.id = jsonObject.getLong("id");
        return status;
    }

    public boolean isStatusSet() {
        return id != STATUS_NOT_SET_ID;
    }

    @Override
    public String toString() {
        return "Status{" +
                "time=" + time +
                ", activity='" + activity + '\'' +
                ", id=" + id +
                ", uid=" + uid +
                '}';
    }
	public long getOwner() {
		return uid;
	}
    
        
}
